<?php
	include_once('auth.php');
	include_once('config.php');

	if (!empty($_POST))
	{
		$preview_link = $_POST['link'];
		
		$preview_id = (int) substr(parse_url($preview_link, PHP_URL_PATH), 1);
		
		global $preview_dir;
		$dir = $preview_dir.$preview_id;
		$preview_img = $dir.'/'.$preview_id.'.jpg';
		file_put_contents($preview_img, file_get_contents(getVideoImage($preview_id)));;
	}
	else
	{
		header('Location: /admin');
		exit();
	}
?>